window.onload = function(){
    //设置结束时间
    var endTime = new Date("2018-11-23 21:10:10");
    function seckill(){

    //获取当前时间
    var nowTime = new Date();

    //获取剩余毫秒数
    var interval = endTime.getTime() - nowTime.getTime();

    //在少于1秒时，清理定时任务
    if(interval <= 999){
        clearInterval(timer);
    }

    //剩余天数
    var day = Number.parseInt( interval / (24 * 60 * 60 * 1000));

    //剩余的小时
    var hour =Number.parseInt((interval - day *(24 * 60 *60 * 1000)) / (60 * 60 * 1000));

    //剩余的分钟
    var minute =Number.parseInt((interval % (60 * 1000)) / (60 * 1000));

    //剩余的秒
    var second = Number.parseInt((interval % (60 * 1000)) / (1000));

    //更新界面
    daydiv = document.getElementsByClassName('day')[0];
    daydiv.innerHTML = day+"天";
    
    hourdiv = document.getElementsByClassName('hour')[0];
    hourdiv.innerHTML = hour+"时"; 

    minutediv = document.getElementsByClassName('minute')[0];
    minutediv.innerHTML = minute+"分"; 

    seconddiv = document.getElementsByClassName('second')[0];
    seconddiv.innerHTML = second+"秒"; 
  }
  setInterval(seckill,1000);
}